package pms.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import pms.om.Event;
import pms.om.Kunde;
import pms.om.Rechnung;


/** 
 * Controller to generate the Home Page basics to be rendered by a view. 
 * It extends the convenience class AbstractController that encapsulates most 
 * of the drudgery involved in handling HTTP requests. 
 * @author KRS DEV Team (krsdevteam@PMSWIbb2011SS.de)
 */
public class SaveReservierung extends AlleReservierungen {
	protected ModelAndView handleRequestInternal(
			HttpServletRequest httpServletRequest,
			HttpServletResponse httpServletResponse) throws Exception {
		
		httpServletRequest.setCharacterEncoding("UTF-8");
		int kundeId = Integer.parseInt(httpServletRequest.getParameter("kundeId"));
		int eventId = Integer.parseInt(httpServletRequest.getParameter("eventId"));
			
		String name = httpServletRequest.getParameter("name");
		String vorname = httpServletRequest.getParameter("vorname");
		String strasse = httpServletRequest.getParameter("strasse");
		String plz = httpServletRequest.getParameter("plz");
		String ort = httpServletRequest.getParameter("ort");
		String tel = httpServletRequest.getParameter("tel");
		String email = httpServletRequest.getParameter("email");
		String kto = httpServletRequest.getParameter("kto");
		String blz = httpServletRequest.getParameter("blz");
		String bank = httpServletRequest.getParameter("bank");
		
		getKundeDao().create(name, vorname, strasse, plz, ort, tel, email, kto, blz, bank);
		
		/*
		int i1 = Integer.parseInt(httpServletRequest.getParameter("res_plaetze_loge"));
		int i2 = Integer.parseInt(httpServletRequest.getParameter("res_plaetze_reg"));
		String d = "01.06.2011";
		
		String last_ins = getKundeDao().lastInsert();
		int li = Integer.parseInt(last_ins);		
		
		Event e = new Event();
		e.setId(eventId);
		
		Rechnung r = new Rechnung();
		r.setId(1);		
		
		getReservierungDao().create(i1, i2, d, e, k, r);
		*/

		return super.handleRequestInternal(httpServletRequest, httpServletResponse);
	}

}
